Battle.SpecialExit = false;

function PireForestSpecial()
{
  FadeToColor(500, Black);
  eatKey();
  DetachCamera();
  DetachInput();
  BindKey(KEY_ESCAPE, "", "");
  ChangeMap("Pire_Forest.rmp");
  if (Player.chrclass == "Bard")
  {
  SetPersonX("main character", 1527);
  SetPersonY("main character", 1750);
  }
  else
  {  
  SetPersonX("main character", 1527);
  SetPersonY("main character", 1752);
  }
  SetPersonLayer("main character", 2);
  SetPersonDirection("main character", 0);
  SetPersonFrame("main character", 0);
  CreatePerson("Dagnar", "Dagnar.rss", true)
  SetPersonX("Dagnar", 1543);
  SetPersonY("Dagnar", 1750);
  SetPersonLayer("Dagnar", 2);
  SetPersonDirection("Dagnar", 0);
  SetPersonFrame("Dagnar", 0);
  SetCameraX(1528);
  SetCameraY(1512);
  RenderMap();
  FadeFromColor(500, Black);
  eatKey();
MiscPersonMove("Dagnar", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 512, 1);
MiscPersonMove("main character", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 512, 1);
SetDelayScript(513, "PireForestSpecial1_5()");
}
function PireForestSpecial1_5()
{
  SetPersonFrame("main character", 0);
  SetPersonFrame("Dagnar", 0);
  RenderMap();
  SetDelayScript(39, "PireForestSpecial2()");
}
function PireForestSpecial2()
{
  SetPersonFrame("main character", 0);
  SetPersonFrame("Dagnar", 0);
  RenderMap();
  Delay(500);
  Talk_Window(Player.name + ": So this is it, Pire Forest.", Player.port);  
  RenderMap();
  FlipScreen();
  Delay(500);
  SetPersonDirection("Dagnar", 6);
  Talk_Window("Dagnar: Let's just get this over with.", Player2.port);  
  RenderMap();
  FlipScreen();
  Delay(200);
  SetPersonDirection("main character", 2);
  RenderMap();
  ClearPersonCommands("main character");
  ClearPersonCommands("Dagnar");
  NodAni("main character", "East")
  SetDelayScript(40, 'PireForestSpecial2_5()');
}
function PireForestSpecial2_5()
{
  Delay(200);
  Talk_Window(Player.name + ": Agreed.", Player.port);  
  RenderMap();
  FlipScreen();
  Delay(500);
  RenderMap();
  FadeToColor(500, Black);
  SetCameraY(GetPersonY("main character"));
  SetCameraX(GetPersonX("main character"));
  Player.event3 = true;
  DestroyPerson("Dagnar");
  RenderMap();
  Delay(200);
  FadeFromColor(500, Black);
  eatKey();
  AttachInput("main character");
  AttachCamera("main character");
  ClearPersonCommands("main character");
  BindKey(KEY_ESCAPE, "GameMenu()", "");
  GetintoBattle("PireForest1", 3);
}

function PireForestSpecial3()
{
  if (Player.event4 == false)
  {
  FlipScreen();
  Delay(200);
  DetachInput();
  Battle.prevent = true;
  Battle.ExitTemp = 1;
  Talk_Window(Player.name + ": Wait.  What was that sound?", Player.port);
  Delay(200);
  Talk_Window("Dagnar: Sound?  I never heard anything.", Player2.port);
  Delay(200);
  Battle.prevent = false;
  Battle.SpecialExit = true;
  EngageBattle("PireForestBoss");
  Battle.SpecialExit = false;
  PireForestSpecial4();
  }
}
function PireForestSpecial4()
{
SetCameraY(GetPersonY("main character"));
SetCameraX(GetPersonX("main character"));
RenderMap();
Font.drawTextBox (55, 15, 525, 60, 5, " ");//75, 380, 525, 100, 5
FlipScreen();
Delay(300);
Player.event4 = true;
Talk_Window("Dagnar: Oh, you mean THAT sound.", Player2.port);
Delay(200);
SetPersonDirection("main character", 2);
Talk_Window(Player.name + ": You're hopeless." , Player.port);
Delay(200);
  
  if (Player.chrclass == "Ranger")
  {
  SetPersonDirection("Dagnar", 6);
  Talk_Window("Dagnar: Oh and by the way, since we're half-way there already, why don't we go to Tork and watch the tournament?  I've got a ticket here with your name on it." , Player2.port);
  Delay(200);
  Talk_Window(Player.name + ": You manipulating little scoundrel!  I knew you were up to something when you asked to come with me!" , Player.port);
  Delay(200);
  Talk_Window("Dagnar: Oh come on, lighten up.  It's not that far, it won't delay us too long.", Player2.port);
  Delay(200);
  Talk_Window(Player.name + ": Fine.  But remind me to kill you when we get back.", Player.port);
  Delay(200);
  LaughPerson("Dagnar", "yes");
  SetDelayScript(100, 'PireForestSpecial5()');
  }
  else
  {
  RenderMap();
  FadeToColor(500, Black);
  Delay(200);
  DestroyPerson("Dagnar");
  RenderMap();
  FadeFromColor(500, Black);
  }
}
function PireForestSpecial5()
{ 
Talk_Window("Dagnar: Ha ha!  Cold as stone.", Player2.port);
Delay(200);
Talk_Window(Player.name + ": Oh shut up!", Player.port);
Delay(200);
Player.quest = "Travel with Dagnar to Tork";
SetPersonDirection("Dagnar", 8);
SetPersonFrame("Dagnar", 1);
RenderMap();
Font.drawTextBox (55, 15, 525, 60, 5, " ");//75, 380, 525, 100, 5
FlipScreen();
Delay(700);

RenderMap();
FadeToColor(500, Black);
Delay(200);
SetCameraY(GetPersonY("main character"));
SetCameraX(GetPersonX("main character"));
DestroyPerson("Dagnar");
RenderMap();
FadeFromColor(500, Black);
Delay(200);
AttachInput("main character");  
}

function BattleSpecialExit()
{
  if (Battle.ExitTemp == 1)
  {
  CreatePerson("Dagnar", "Dagnar.rss", true)
  SetPersonX("Dagnar", 1688);
  SetPersonY("Dagnar", 518);
  SetPersonLayer("Dagnar", 2);
  SetPersonDirection("Dagnar", 0);
  SetPersonX("main character", 1672);
  SetPersonY("main character", 520);
	SetCameraY(GetPersonY("main character"));
	SetCameraX(GetPersonX("main character"));
		if (Player.chrclass == "Bard")
		{
		SetPersonY("main character", 518); 
		}
  SetPersonDirection("main character", 0);
  }
}

function TorkPubSpecial1()
{

  WindowStyle.drawWindow (25, 380, 590, 80);
  Font.drawTextBox (75, 400, 525, 50, 5,   "Malla:  I know, I know, I'm just tormenting you that's all.  Anyway, would you like a drink?");

  RenderMap();
  // create the menu object
  var PubMenu = new Menu();
  PubMenu.arrow           = Arrow;
  PubMenu.font            = Font;
  PubMenu.window_style    = WindowStyle;
  PubMenu.escape_function = InnmenuNo;

  // add the commands to it
  PubMenu.addItem("Yeah",     PubmenuYes);
  PubMenu.addItem("No Thanks",    PubmenuNo );
  PubMenu.execute(515, 350, 100, 20);
}
function PubmenuYes()
{
Delay(200);
Talk_Window("Malla: Here ya go, on the house.", "blank.png")
Delay(200);
Talk_Window(Player.name + ": Sweet!", Player.port)
Delay(200);
TorkPubSpecial2();
}
function PubmenuNo()
{
Delay(200);
Talk_Window("Malla: Are you sure?  It's on the house.", "blank.png")
Delay(200);
Talk_Window(Player.name + ": Well... Oh what the heck, one drink won't hurt.", Player.port)
Delay(200);
TorkPubSpecial2();
}

function TorkPubSpecial2()
{
RenderMap();
FadeToColor(500, Black);
SetTile(29, 20, 2, 4);
SetTile(29, 21, 2, 4);
SetTile(11, 20, 2, 4);
SetTile(11, 21, 2, 4);
SetTile(11, 20, 3, 4);
SetTile(11, 21, 3, 4);
SetPersonX("main character", 440);
SetPersonY("main character", 312);
SetCameraX(440);
SetCameraY(312);
CreatePerson("Dagnar", "Dagnar.rss", true);
SetPersonX("Dagnar", 407);
SetPersonY("Dagnar", 440);
SetPersonLayer("Dagnar", 1);

DestroyPerson("TorkInnP1");
DestroyPerson("TorkInnP2");
DestroyPerson("TorkInnP3");
DestroyPerson("TorkInnP4");
DestroyPerson("TorkInnP5");
DestroyPerson("TorkInnP6");
DestroyPerson("TorkInnP7");
DestroyPerson("TorkInnP8");
DestroyPerson("TorkInnP9");
SetPersonFrame("main character", 0);
SetPersonDirection("main character", 9);
RenderMap();
FadeFromColor(500, Black);
Delay(400);
Talk_Window(Player.name + ": Ooohhhh, my head.", Player.port);
Delay(200);
Font.drawText (75, 400, "");
RenderMap();
FlipScreen();
PlaySound("click.wav");
Delay(200);
MiscPersonMove("Dagnar", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 64, 1);
MiscPersonMove("Dagnar", COMMAND_MOVE_EAST, COMMAND_FACE_EAST, 32, 1);
MiscPersonMove("Dagnar", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 48, 1);
SetDelayScript(296, "TorkPubSpecial3()");
}
function TorkPubSpecial3()
{
Delay(200);
Talk_Window("Dagnar: Hey, you ok?", Player2.port);
Delay(200);
Talk_Window(Player.name + ": What happened?  I only had two drinks...", Player.port);
Delay(200);
Talk_Window("Dagnar: Add a few onto that and you'd probably be right.  But nevermind that, the tournament's about to begin.", Player2.port);
Delay(200);
Talk_Window(Player.name + ": Oh CRAP!", Player.port);
Delay(200);

DetachInput();
//DetachCamera();
RenderMap();
FadeToColor(500, Black);
ChangeMap("TorkRing.rmp");
CreatePerson("Magnar", "Magnar.rss", true);
SetPersonX("Magnar",504);
SetPersonY("Magnar",488);
SetPersonLayer("Magnar", 2);
SetPersonDirection("Magnar", 4);

SetTile(18, 36, 3, 353); 
SetPersonX("main character",504);
SetPersonY("main character",792);
SetPersonLayer("main character", 0);
SetCameraX(504);
SetCameraY(648);
RenderMap();
FadeFromColor(500, Black);
eatKey();
Delay(500);
BardTournament1();
}


//Like the Talk_Window function, but meant for battles
function BattleTalk(BTalk, Bport)
{
 RenderMap(); 
 Player.active = "Player1";
 BattleName();
 DrawPlayerStats();
 WindowStyle.drawWindow (5, 5, 630, 55);//25, 330, 590, 130
 Portrait = LoadImage(Bport);
 Portrait.blit(10, 10);
 Font.drawTextBox (55, 15, 525, 60, 5, BTalk);//75, 380, 525, 100, 5
 FlipScreen();
 eatKey()
 while (IsKeyPressed(KEY_SPACE) == false) 
 {Delay(100);}
 {GetKey()}
}


function MiscPersonMove(name, COMMANDMOVE, DIRECTION, TEMPNUM, WAIT)
{
  if (DIRECTION == "")
  {
  }
  else
  {
  QueuePersonCommand(name, DIRECTION, false);
  }
  
 for (var i = 0; i < TEMPNUM; i++) 
 {
  if (WAIT >= 1)
  {
  QueuePersonCommand(name, COMMAND_WAIT, false);
  }
  if (WAIT >= 2)
  {
  QueuePersonCommand(name, COMMAND_WAIT, false);
  }
  if (WAIT >= 3)
  {
  QueuePersonCommand(name, COMMAND_WAIT, false);
  }
  QueuePersonCommand(name, COMMANDMOVE, false);
 }
}

function TorkCafeSpecial()
{
SetPersonDirection("TorkCafeKeep", 2);
Talk_Window("CafeKeep: I mean, What was I thinking?  Opening a cafe right next to the cheapest pub west of Glace?  Open for two weeks so far and I'm already 5000 in debt.", "blank.png"); 
Delay(200);
SetPersonDirection("TorkCafeKeep", 4);
RenderMap();
Talk_Window("CafeKeep: What?  Someone's here?!", "blank.png"); 
MiscPersonMove("TorkCafeKeep", COMMAND_MOVE_SOUTH, COMMAND_FACE_SOUTH, 48, 0);
MiscPersonMove("TorkCafeKeep", COMMAND_MOVE_WEST, COMMAND_FACE_WEST, 48, 0);
MiscPersonMove("TorkCafeKeep", COMMAND_MOVE_SOUTH, COMMAND_FACE_SOUTH, 16, 0);
SetDelayScript(116, "TorkCafeSpecial2()");
}

function TorkCafeSpecial2()
{
Talk_Window("CafeKeep: Can I get you anything? A cup of coffee, tea, a chair, a table, napkins, a fork, knife, spoon, a hot towel, a free 'I love Cafes' pin, huh huh huh?", "blank.png");
Delay(200);
Talk_Window(Player.name + ": Sorry, wrong building.", Player.port);
Delay(200);
Player.event6 = true;
Font.drawText(100, 100, " ");
RenderMap();
FlipScreen();
NewMap("TorkMain.rmp", 584, 1192, 1, 4);
Talk_Window(Player.name + ": I don't know if that was weird or just plain scary.", Player.port);
Delay(200);
Talk_Window("Dagnar: Must be smelling coffee all the time.  It makes you crazy ya know.", Player2.port);
Delay(200);
Talk_Window(Player.name + ": Yeah, sure.  Whatever.", Player.port);
Delay(200);
}

function RHmenuYes()
{
Delay(200);
Talk_Window("Bill: Ok!  Take them out!", "blank.png")
Delay(200);
NewMap("TorkApp.rmp", 760, 840, 1, 0);
Delay(200);
Talk_Window("Bill: Here they come!", "blank.png")
Delay(200);
Battle.prevent = false;
EngageBattle("Two Rats");  

}
function RHmenuNo()
{
Delay(200);
Talk_Window("Bill:  Oh well.  Come back again if you change your mind.", "blank.png")
Delay(200);
DeFacePlayer("TorkRHP1");
}

function SoldierTournament()
{
DetachInput();
DetachCamera();
RenderMap();
FadeToColor(500, Black);
ChangeMap("TorkRing.rmp");
CreatePerson("Magnar", "Magnar.rss", true);
SetPersonX("Magnar",504);
SetPersonY("Magnar",488);
SetPersonLayer("Magnar", 2);
SetPersonDirection("Magnar", 4);

SetPersonX("main character",504);
SetPersonY("main character",792);
SetPersonLayer("main character", 0);
SetCameraX(504);
SetCameraY(792);
RenderMap();
FadeFromColor(500, Black);
eatKey();
Delay(500);
SoldierTournament1();
}

function SoldierTournament1()
{

Talk_Window("Announcer:  The next heat will now commence.  Introducing the first combatant... " + Player.name + "!  A Soldier stationed in Pire.", "blank.png");
AttachCamera("main character");
MiscPersonMove("main character", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 176, 0);
QueuePersonCommand("main character", COMMAND_FACE_SOUTH, false);
SetDelayScript(180, "SoldierTournament2()");
}
function SoldierTournament2()
{
SetPersonFrame("main character", 0);
CreatePerson("Strike", "soldier2.rss", true);
SetPersonX("Strike",504);
SetPersonY("Strike",792);
SetPersonLayer("Strike", 0);
Talk_Window("Announcer:  And now his opponent, the one called 'Strike', a Ranger from the north.", "blank.png");
MiscPersonMove("Strike", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 96, 0);
SetDelayScript(98, "SoldierTournament3()");
}
function SoldierTournament3()
{
SetPersonFrame("Strike", 0);
Talk_Window("Announcer:  Gentlemen, draw your weapons!", "blank.png");
Delay(200);
EngageIntoTournBattle();
}

function EngageIntoTournBattle()
{
BindKey(KEY_ESCAPE, "GoToActivePlayer()", "GoToActivePlayer()");
Player_x = GetPersonX("main character");
Player_y = GetPersonY("main character");

Player.tempystr = Player.str
Player2.tempystr = Player2.str
Player3.tempystr = Player3.str
Player.str = Player.attack;
Player2.str = Player2.attack;
Player3.str = Player3.attack;
Player.stun = 0;
Player2.stun = 0;
Player3.stun = 0;

Battle.monsternum = 1;
Monster1.name =  "Strike";  
Monster1.hp = 200;
Monster1.maxhp = 200;
Monster1.mp = 20;
Monster1.maxmp = 20;
Monster1.vit = 35;
Monster1.defence = 45;
Monster1.str = 45;
Monster1.attack = 45;
Monster1.agi = 20;
Monster1.evade = 4;
Monster1.mag = 30;
Monster1.luck = 20;
Monster1.exp = 200;
Monster1.gold = 0;
Monster1.weak = "None";
Monster1.strong = "None";
Monster1.immune = "None";
Monster1.absorb = "None"; 
Monster1.runchance = 0.0;
Monster1.run = 0;
Monster1.specialchance = 0.25;
Monster1.special1 = "Heal";
Monster1.special2 = "Heal";
Monster1.special3 = "Heal";
Monster1.special4 = "Heal";
Monster1.ai = "Standard";
  
CreatePerson("Monster1", "blank.rss", true);  
SetPersonX("Monster1", Player_x);
SetPersonY("Monster1", 636);
SetPersonLayer("Monster1", 0);
Monster1.posx = 320;
Monster1.posy = 308;
Player.tournamentpres = true;
Delay(200);

Player.P1x = 320;
Player.P1y = (Player_y - 388);

Player.hp = Player.maxhp;
Player.mp = Player.maxmp;
  
Player2.pres = false;
Player3.pres = false;

DetachInput();
DetachCamera();
BattleMenuPlayer1();  
}

function TournamentStop1(winlose)
{
DetachInput();
  if (winlose == "Win")
  {
  Talk_Window("Announcer:  And the match goes to " + Player.name + "!", "blank.png");
  }
  else
  {
  Talk_Window("Announcer:  And the match goes to Strike!", "blank.png");
  }
  Player2.pres = true;
  Player.tournamentpres = false;
  Delay(200);
  RenderMap();
  Font.drawText (0, 0, "");
  FlipScreen();
  Delay(200);
  ChangeMusic("");
  FlipScreen();
  Delay(1000);
  
  WindowStyle.drawWindow (25, 380, 590, 80);
  Font.drawTextBox (75, 400, 525, 60, 5, "Announcer: What?  What's going on?");//75, 380, 525, 100, 5
  FlipScreen();
  eatKey()
  while (IsKeyPressed(KEY_SPACE) == false) 
  {Delay(100);}
  {GetKey()}
  Font.drawText (75, 400, "");
  FlipScreen();
  Delay(1700);

  RenderMap();
  Font.drawText (75, 400, "");
  FlipScreen();
  Delay(1500);
  Battle.prevent = true;
  GarbageCollect();
  MiscPersonMove("Magnar", COMMAND_MOVE_SOUTH, COMMAND_FACE_SOUTH, 16, 1);
  SetDelayScript(48, "TournamentStop1_5()");
}
function TournamentStop1_5()
{
  SetPersonFrame("Magnar", 0);
  Talk_Window("Magnar: I'm sorry ladies and gentlemen, but there appears to be a problem with the lighting.  I hearby postpone the rest of the tournament until this problem is fixed.  Please, come back again tomorrow.", "blank.png");
  Delay(200);
  
  if (Player.chrclass == "Mage")
  {
  BardTournament3();
  }
  else
  {
  RenderMap();
  FadeToColor(500, Black);
  ChangeMap("TorkArena.rmp");
  DestroyPerson("TicketTaker");
  CreatePerson("Dagnar", "Dagnar.rss", true);
  SetPersonX("Dagnar", 552);
  SetPersonY("Dagnar", 504);
  SetPersonLayer("Dagnar", 1);
  SetPersonDirection("Dagnar", 6);
  SetPersonDirection("main character", 2);
  SetPersonFrame("Dagnar", 0);
  SetPersonFrame("main character", 0);

  SetPersonX("main character", 536);
  SetPersonY("main character", 504);
  SetPersonLayer("main character", 1);

  SetCameraX(536);
  SetCameraY(504);
  RenderMap();
  FadeFromColor(500, Black);
  eatKey();
  if (Player.chrclass == "Soldier")
  {
  Talk_Window("Dagnar: Nice try " + Player.name + ", but it looks like there won't be any more fighting for you.  Well, for a little while anyway.", Player2.port);
  Delay(200);
  Talk_Window(Player.name + ": And where exactly were you?  I couldn't see YOU anywhere.", Player.port);
  Delay(200);
  Talk_Window("Dagnar: What?  You couldn't see me way in the back of the top balcony?  I'm shocked!", Player2.port);
  Delay(200);
  }
  else
  {
  Talk_Window("Dagnar: What a shame, but it looks like we'll have to wait a while for the next match.", Player2.port);
  Delay(200);
  Talk_Window(Player.name + ": And I had to waste my time here because you wanted me to come with you.", Player.port);
  Delay(200);
  Talk_Window("Dagnar: Hey, it always gets better with the final few matches.", Player2.port);
  Delay(200);
  }
  Talk_Window(Player.name + ": Let's just get a place for the night ok?", Player.port);
  Delay(200);
  Talk_Window("Dagnar:  Sure, I could use a bit of rest.  But I'm a bit low on cash, you'll have to pay.", Player2.port);
  Delay(200);
  Talk_Window(Player.name + ": What's with you anyway?  Always trying to get away with doing or paying for nothing.", Player.port);
  Delay(200);
  CreatePerson("Magnar", "Magnar.rss", true);
  SetPersonX("Magnar", 536);
  SetPersonY("Magnar", 440);
  SetPersonLayer("Magnar", 1);
  Talk_Window("Dagnar:  Really, I'm a bit low on cash ok?  I'll pay you later when I get some.", Player2.port);
  Delay(200);
  SetTile(33, 28, 1, 312);
  SetTile(33, 29, 1, 313);
  PlaySound("click.wav");
  MiscPersonMove("Magnar", COMMAND_MOVE_SOUTH, COMMAND_FACE_SOUTH, 48, 1);
  SetDelayScript(100, "TournamentStop2()");
  }
}
function TournamentStop2()
{
SetPersonFrame("Magnar", 0);
SetPersonDirection("main character", 0);
SetPersonDirection("Dagnar", 0);
if (Player.chrclass == "Ranger")
{
SetPersonY("Dagnar", 502);
}
Player.quest = "Meet Garret in Zien";
Delay(200);
Talk_Window("Magnar: You are " + Player.name + " I presume?", "blank.png");
Delay(200);
Talk_Window(Player.name + ": Yes, I am.", Player.port);
Delay(200);
Talk_Window("Magnar: Excellent.  I talked to your friend here moments ago, and he says that both of you know the Zien and Glace areas very well.  Is that correct?", "blank.png");
Delay(200);
Talk_Window(Player.name + ": Yes.", Player.port);
Delay(200);
Talk_Window3("Magnar: Good, because I need your help.  You see, after your match there was no lighting problem, someone turned them off and stole a potion I had on my person.  It's very valuable and it was going to be the prize for the winner of this tournament.", "blank.png");
Delay(200);
Talk_Window3("Magnar: I said there was a lighting error because I didn't want rumours to go around and ruin the tournament's reputation.  Imagine how much talk there would be with the main prize being stolen during the third match.", "blank.png");
Delay(200);
Talk_Window3("Magnar: However, some of the guards noticed someone with bleached white hair in a dark cape come into the building just before the lightout and leave through the east end of town shortly after, most likely headed for Zien.", "blank.png");
Delay(200);
Talk_Window("Magnar: Please find who ever this is and bring him back to me, whether he has the potion or not.  I would go myself but I'm needed here, and I haven't been to Zein for years.", "blank.png");
Delay(200);
Talk_Window(Player.name + ": Don't worry sir, we'll do what we can to help.  I just hope I have enough vacation time left...", Player.port);
Delay(200);
SetPersonDirection("Dagnar", 6);
FingerAni("Dagnar", "yes")
SetDelayScript(60, 'TournamentStop2_5()');
}
function TournamentStop2_5()
{
Talk_Window("Dagnar: Hey, don't sweat it!  If we explain the situation to our commanding officer in Zien, he'll understand.", Player2.port);
Delay(200);
SetPersonFrame("Dagnar", 0);
SetPersonDirection("Dagnar", 0);
Talk_Window3("Magnar: I thank both of you again.  But while you're in Zien I would appreciate it if you talked a friend of mine there.  His name is Garret and he will make for a very trustworthy ally should you have any problems along the way.", "blank.png");
Delay(200);
Talk_Window(Player.name + ": I'm sure this 'Garret' will be a great help.", Player.port);
Delay(200);
SetPersonDirection("main character", 2);
Talk_Window(Player.name + ": Now Dagnar, I believe we have an adventure ahead of us.", Player.port);
Delay(200);
SetPersonDirection("main character", 0);
Talk_Window("Magnar: Good luck.  I hope to see you back here soon.", "blank.png");
Delay(200);
DagnarNewArmour1(600, 696);
}
function DagnarNewArmour1(thex, they)  
{
  Player.hp = Player.maxhp;
  Player.mp = Player.maxmp;
  RenderMap();
  FadeToColor(500, Black);
  ChangeMap("TorkMain.rmp");
  SetPersonX("main character", thex);
  SetPersonY("main character", they);
  SetPersonLayer("main character", 1);
  SetPersonDirection("main character", 4);
  SetCameraX(thex);
  SetCameraY(they);
  AttachInput("main character");
  AttachCamera("main character");
  RenderMap();
  FadeFromColor(500, Black);
  eatKey();
  Talk_Window("Dagnar: Oh, by the way, what do you think of my new armour?  I bought it just before the tournament started.", Player2.port);
  Delay(200);
  if (Player.chrclass == "Mage" || Player.chrclass == "Bard")
  {
  Talk_Window(Player.name + ": Yeah, yeah, whatever.  I'll ask about it when I start to care.", Player.port);
  Delay(200);
  }
  else
  {
  Talk_Window(Player.name + ": I thought you said you had no money!", Player.port);
  Delay(200);
  Talk_Window("Dagnar: Come on, what did you think I'd do: Save my money in case we needed it, or buy some new armour?  I think the choice was obvious.", Player2.port);
  Delay(200);
  Talk_Window(Player.name + ": I said it before, I'll say it again: You're hopeless.", Player.port);
  Delay(200);
  }
  Player2.equiparmour = "Studded Leather Armour";
  Player2.armoureffect = 25;
  Player2.def = Player2.def + 25;
  Playerweapons.Lh_Armour = Playerweapons.Lh_Armour + 1;
  Player.event8 = 1;
  AttachCamera("main character");
  BindKey(KEY_ESCAPE, "GameMenu()", "");
}
function RangerTournament1()
{
DetachInput();
DetachCamera();
RenderMap();
FadeToColor(500, Black);
ChangeMap("TorkRing.rmp");
CreatePerson("Magnar", "Magnar.rss", true);
SetPersonX("Magnar",504);
SetPersonY("Magnar",488);
SetPersonLayer("Magnar", 2);
SetPersonDirection("Magnar", 4);

SetPersonX("main character",0);
SetPersonY("main character",0);
SetPersonLayer("main character", 0);
SetCameraX(504);
SetCameraY(792);
SetTile(18, 36, 3, 353); 
SetTile(18, 37, 3, 354); 
RenderMap();
FadeFromColor(500, Black);
eatKey();
Delay(500);
RangerTournament2();
}
function RangerTournament2()
{
DetachCamera();
Talk_Window("Announcer:  The next heat will now commence.  Introducing the first combatant... Galron!  A Soldier stationed right here in Tork.", "blank.png");
CreatePerson("Galron", "soldier.rss", true);
SetPersonX("Galron", 504);
SetPersonY("Galron", 792);
SetPersonLayer("Galron", 0);
if (Player.chrclass == "Ranger")
{
AttachCamera("Galron");
}
MiscPersonMove("Galron", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 176, 0);
QueuePersonCommand("Galron", COMMAND_FACE_SOUTH, false);
SetDelayScript(180, "RangerTournament4()");
}
function RangerTournament4()
{
SetPersonFrame("Galron", 0);
CreatePerson("Strike", "soldier2.rss", true);
SetPersonX("Strike",504);
SetPersonY("Strike",792);
SetPersonLayer("Strike", 0);
Talk_Window("Announcer:  And now his opponent, the one called 'Strike', a Ranger from the north.", "blank.png");
MiscPersonMove("Strike", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 96, 0);
SetDelayScript(98, "RangerTournament5()");
}
function RangerTournament5()
{
SetPersonFrame("Strike", 0);
Talk_Window("Announcer:  Gentlemen, draw your weapons!", "blank.png");
Delay(200);
RenderMap();
Font.drawText (0, 0, "");
FlipScreen();
Delay(200);
FlipScreen();
ChangeMusic("");
Delay(1000);
  
WindowStyle.drawWindow (25, 380, 590, 80);
Font.drawTextBox (75, 400, 525, 60, 5, "Announcer: What?  What's going on?");//75, 380, 525, 100, 5
FlipScreen();
eatKey()
while (IsKeyPressed(KEY_SPACE) == false) 
{Delay(100);}
{GetKey()}
Font.drawText (75, 400, "");
FlipScreen();
Delay(1700);

RenderMap();
Font.drawText (75, 400, "");
FlipScreen();
Delay(1500);
MiscPersonMove("Magnar", COMMAND_MOVE_SOUTH, COMMAND_FACE_SOUTH, 16, 1);
SetDelayScript(48, "TournamentStop1_5()");
}

function BardTournament1()
{
DetachCamera();
Delay(500);
Talk_Window("Announcer:  And what an exciting match that was.  But let's break away now to listen to the incredible " + Player.name + " sing 'Orex, Pangara'.", "blank.png");
MiscPersonMove("main character", COMMAND_MOVE_NORTH, COMMAND_FACE_NORTH, 176, 1);
QueuePersonCommand("main character", COMMAND_FACE_SOUTH, false);
SetDelayScript(356, "BardTournament2()");
}
function BardTournament2()
{
SetPersonFrame("main character", 0);
Talk_Window(Player.name + ": Ladies and gentlemen, this is a song that was written shortly after the war between Pangara and Hettra ended.  It's about a man named Tom, who had to leave his town to find work.  Ahem.", Player.port);
RenderMap();
FlipScreen();
Delay(200);
SetPersonDirection("main character", 8);
SetPersonFrame("main character", 9);
RenderMap();
Delay(200);

BardSong1();

SetPersonDirection("main character", 4);
SetPersonFrame("main character", 0);
RenderMap();
Font.drawText (0, 0, "");
FlipScreen();
Delay(500);
FlipScreen();
ChangeMusic("");
Delay(1000);
  
WindowStyle.drawWindow (25, 380, 590, 80);
Font.drawTextBox (75, 400, 525, 60, 5, "Announcer: What?  What's going on?");//75, 380, 525, 100, 5
FlipScreen();
eatKey()
while (IsKeyPressed(KEY_SPACE) == false) 
{Delay(100);}
{GetKey()}
Font.drawText (75, 400, "");
FlipScreen();
Delay(1700);

RenderMap();
Font.drawText (75, 400, "");
FlipScreen();
Delay(1500);
MiscPersonMove("Magnar", COMMAND_MOVE_SOUTH, COMMAND_FACE_SOUTH, 16, 1);
SetDelayScript(48, "BardTournament3()");
}

function BardTournament3()
{
  Player.quest = "Meet Garret in Zien";
  SetPersonFrame("Magnar", 0);
  Talk_Window("Magnar: I'm sorry ladies and gentlemen, but there appears to be a problem with the lighting.  I hearby postpone the rest of the tournament until this problem is fixed.  Please, come back again tomorrow.", "blank.png");
  Delay(200);

  RenderMap();
  FadeToColor(500, Black);
  ChangeMap("TorkApp.rmp");
  CreatePerson("Dagnar", "Dagnar.rss", true);
  SetPersonX("Dagnar", 216);
  SetPersonY("Dagnar", 776);
  SetPersonLayer("Dagnar", 1);
  SetPersonDirection("Dagnar", 2);

  SetPersonX("Magnar", 248);
  SetPersonY("Magnar", 792);
  SetPersonLayer("Magnar", 1);
  SetPersonDirection("Magnar", 6);

  SetPersonDirection("main character", 2);
  SetPersonX("main character", 216);
  SetPersonY("main character", 792);
  SetPersonLayer("main character", 1);

  SetCameraX(232);
  SetCameraY(792);
  RenderMap();
  FadeFromColor(500, Black);
  eatKey();
  Delay(500);
  if (Player.chrclass == "Bard")
  {
  Talk_Window("Magnar: You did a fine job " + Player.name + ", and as I promised, here is your well deserved reward.", "blank.png");
  Delay(200);
  Talk_Window("Received 750Gp!", "blank.png");
  Player.gp = Player.gp + 750;
  Delay(200);
  Talk_Window(Player.name + ": Thank you very much.", Player.port);
  Delay(200);
  Talk_Window2("Magnar: But giving you your money was not the only reason why I called you here.  You see, the blackout after your song was not a problem with the lights.  Someone stole a potion I had on my person.  It is a very powerful potion and I was going to give it to the winner of the tournament.", "blank.png");
  Delay(200);
  }
  else
  {
  Talk_Window2("Magnar: Now, as for why I called you here.  You see, the blackout during the third match was not a problem with the lights.  Someone stole a potion I had on my person.  It is a very powerful potion and I was going to give it to the winner of the tournament.", "blank.png");
  Delay(200);
  }
  Talk_Window("Magnar: I was hoping that you would help and bring back whoever stole it from me.", "blank.png");
  Delay(200);  
  Talk_Window(Player.name + ": I would be glad to help but I don't even know where to start.", Player.port);
  Delay(200);
  Talk_Window("Magnar: The person in question was seen leaving by some guards shortly after the blackout.  He was in a dark cape and had white hair, but he's not old, probably in his twenties.  The guards say he left town on the east road, and was alone.", "blank.png");
  Delay(200);
  if (Player.chrclass == "Bard")
  {
  Talk_Window(Player.name + ": Oh well, looks like I got some more traveling ahead of me...", Player.port);
  Delay(200);
  SetPersonDirection("Dagnar", 4);
  Talk_Window("Dagnar: It'll be exciting!  The joy of the friendly towns and the not so friendly monsters.  Where's your sense of adventure?", Player2.port);
  Delay(200);
  SetPersonDirection("main character", 0);
  Talk_Window(Player.name + ": Sense of adventure?!  I got more of a 'sense of adventure' than you ever will you knob.  I just got a spliting headache that's all.", Player.port);
  Delay(200);
  Talk_Window("Magnar: Before this gets out of hand, let's get to why I called you here shall we?", "blank.png");
  Delay(200);
  SetPersonDirection("Dagnar", 2);  
  SetPersonDirection("main character", 2);
  Talk_Window2("Magnar: Thank you.  Your search should begin in Zien, if this person has taken to the east road they will most likely go through Zien on the way.  But there is another reason: There's a friend of mine living there, his name is Garret, and he will be a great help to you.  Just explain the situation to him and he will understand.", "blank.png");
  Delay(200);
  }
  else
  {
  Talk_Window2("Magnar: Your search should begin in Zien, if this person has taken to the east road they will most likely go through Zien on the way.  But there is another reason: There's a friend of mine living there, his name is Garret, and he will be a great help to you.  Just explain the situation to him and he will understand.", "blank.png");
  Delay(200);
  }
  Talk_Window(Player.name + ": Garret... I remember hearing that name before...", Player.port);
  Delay(200);
  Talk_Window("Magnar: I'm sure you have, but I would prefer if you started your journey as quickly as possible.  The more time you waste here, the more the trail will disappear.", "blank.png");
  Delay(200);
  Talk_Window(Player.name + ": We'll get right on it!", Player.port);
  Delay(200);
  Talk_Window("Magnar: Thank you, and good luck.", "blank.png");
  Delay(200);
  DagnarNewArmour1(248, 1048);  
}